/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author GiangLT
 */
@Entity
@Table(name = "TRANSACTION", catalog = "", schema = "SCRATCHCARD")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Transaction.findAll", query = "SELECT t FROM Transaction t"),
    @NamedQuery(name = "Transaction.findByTransId", query = "SELECT t FROM Transaction t WHERE t.transactionPK.transId = :transId"),
    @NamedQuery(name = "Transaction.findByIp", query = "SELECT t FROM Transaction t WHERE t.ip = :ip"),
    @NamedQuery(name = "Transaction.findByAccId", query = "SELECT t FROM Transaction t WHERE t.transactionPK.accId = :accId"),
    @NamedQuery(name = "Transaction.findByTransType", query = "SELECT t FROM Transaction t WHERE t.transType = :transType"),
    @NamedQuery(name = "Transaction.findByTransErr", query = "SELECT t FROM Transaction t WHERE t.transErr = :transErr"),
    @NamedQuery(name = "Transaction.findByTransErrDetail", query = "SELECT t FROM Transaction t WHERE t.transErrDetail = :transErrDetail"),
    @NamedQuery(name = "Transaction.findByAmount", query = "SELECT t FROM Transaction t WHERE t.amount = :amount"),
    @NamedQuery(name = "Transaction.findByCardSerial", query = "SELECT t FROM Transaction t WHERE t.cardSerial = :cardSerial"),
    @NamedQuery(name = "Transaction.findByCardPin", query = "SELECT t FROM Transaction t WHERE t.cardPin = :cardPin"),
    @NamedQuery(name = "Transaction.findByLastUpdatedTime", query = "SELECT t FROM Transaction t WHERE t.lastUpdatedTime = :lastUpdatedTime")})
public class Transaction implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TransactionPK transactionPK;
    @Size(max = 40)
    @Column(name = "IP")
    private String ip;
    @Size(max = 20)
    @Column(name = "TRANS_TYPE")
    private String transType;
    @Size(max = 10)
    @Column(name = "TRANS_ERR")
    private String transErr;
    @Size(max = 100)
    @Column(name = "TRANS_ERR_DETAIL")
    private String transErrDetail;
    @Size(max = 32)
    @Column(name = "AMOUNT")
    private String amount;
    @Size(max = 20)
    @Column(name = "CARD_SERIAL")
    private String cardSerial;
    @Size(max = 20)
    @Column(name = "CARD_PIN")
    private String cardPin;
    @Column(name = "LAST_UPDATED_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastUpdatedTime;

    public Transaction() {
    }

    public Transaction(TransactionPK transactionPK) {
        this.transactionPK = transactionPK;
    }

    public Transaction(String transId, String accId) {
        this.transactionPK = new TransactionPK(transId, accId);
    }

    public TransactionPK getTransactionPK() {
        return transactionPK;
    }

    public void setTransactionPK(TransactionPK transactionPK) {
        this.transactionPK = transactionPK;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getTransType() {
        return transType;
    }

    public void setTransType(String transType) {
        this.transType = transType;
    }

    public String getTransErr() {
        return transErr;
    }

    public void setTransErr(String transErr) {
        this.transErr = transErr;
    }

    public String getTransErrDetail() {
        return transErrDetail;
    }

    public void setTransErrDetail(String transErrDetail) {
        this.transErrDetail = transErrDetail;
    }

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public String getCardSerial() {
        return cardSerial;
    }

    public void setCardSerial(String cardSerial) {
        this.cardSerial = cardSerial;
    }

    public String getCardPin() {
        return cardPin;
    }

    public void setCardPin(String cardPin) {
        this.cardPin = cardPin;
    }

    public Date getLastUpdatedTime() {
        return lastUpdatedTime;
    }

    public void setLastUpdatedTime(Date lastUpdatedTime) {
        this.lastUpdatedTime = lastUpdatedTime;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (transactionPK != null ? transactionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transaction)) {
            return false;
        }
        Transaction other = (Transaction) object;
        if ((this.transactionPK == null && other.transactionPK != null) || (this.transactionPK != null && !this.transactionPK.equals(other.transactionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.thienloc.omap.entity.Transaction[ transactionPK=" + transactionPK + " ]";
    }
    
}
